<template>
    <div class="order">
        <Top text="我的订单"/>
        <div class="list">
            <Item
                v-for="item in orderList" :key='item._id'
                :data="item"
                @click.native='jumpOrder(item._id)'
            />
        </div>
    </div>
</template>

<script>
    import Item from '@/views/Order/Item'
    import {mapState} from 'vuex'
    export default {
        name:"Order-View",
        components:{ Item, },
        methods: {
            jumpOrder(_id){
                this.$router.push({
                    path:"/orderDetails",
                    query:{
                        _id
                    }
                })
            }
        },
        computed:{
            ...mapState('Home',['orderList'])
        },
        created() {
            this.$store.dispatch('Home/getOrder')
        },
        beforeRouteEnter (to, from, next) {
            const user = JSON.parse(sessionStorage.getItem('user'))
            if(user){
                next()
            }else{
                next('/login')
            }
        },
    }
</script>

<style scoped lang="less">
    .list{
        padding: 4vw 4vw 13vw 4vw;
    }
</style>